package com.ctgu.demo.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctgu.demo.dao.DessertMapper;
import com.ctgu.demo.entity.Dessert;
import com.ctgu.demo.service.DessertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program:
 * @description:
 * @author: gh
 * @create: 2020-06-22 12:25
 **/
@Service
public class DessertServiceImpl extends ServiceImpl<DessertMapper, Dessert> implements DessertService {

    @Autowired
    private DessertMapper dessertMapper;

    @Override
    public IPage<Dessert> getAll(int page, int size) {
        QueryWrapper<Dessert> wrapper =new QueryWrapper<Dessert>();
        IPage<Dessert> dessertIPage = dessertMapper.selectPage(new Page<>(page,size), wrapper);
        return dessertIPage;
    }

    @Override
    public IPage<Dessert> selectDessert(String name, int page, int size){
        QueryWrapper<Dessert> dessertIPage = new QueryWrapper<>();
        dessertIPage.like("dessert_id", name).or().like("dessert_name", name).or().like("dessert_maker", name);
        IPage<Dessert> dessertsIPage = dessertMapper.selectPage(new Page<>(page, size), dessertIPage);
        return dessertsIPage;
    }




}
